#!/usr/bin/env python
# encoding: utf-8
'''
@author: zhaowenpeng
@contact: winston@peipeiyun.com
@software: garner
@file: 20200710.py
@time: 2020/7/10 2:40 下午
@desc:
'''

import sys
sys.path.append('../')

from core.migrations import db_manager
from playhouse.migrate import *
from peewee import *
import logging

logger = logging.getLogger('peewee')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
migrator = MySQLMigrator(db_manager)

brand_code = CharField(max_length=30, default='', index=True, verbose_name='品牌编码', help_text='品牌编码')
is_exist = BooleanField(default=False, verbose_name='是否存在', help_text='是否存在')
sale_cars_count = IntegerField(default=0, verbose_name='销售车数量', help_text='销售车数量')
origin_name = CharField(max_length=30, default='',  verbose_name='原厂名称', help_text='原厂名称')

with db_manager.atomic():
    migrate(
        migrator.add_column('parts', 'brand_code', brand_code),
        migrator.add_column('parts', 'is_exist', is_exist),
        migrator.add_column('parts', 'sale_cars_count', sale_cars_count),
        migrator.add_column('parts', 'origin_name', origin_name)
    )
